var app = getApp(), fetchApi = require("../../../utils/httpPost.js");
import Dialog from '../../../component/vant/dialog/dialog';
import Toast from '../../../component/vant/toast/toast';
var common_Js = require("../../../component/common.js");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    imgurl: app.getImgUrl(),
    loading: false,
    netWork: false,
    isLoading: true,
    order_id:0,
    orderinfo:[],
    address: [],
    scrollTop: 0,
    scrollHeight: 0,
    refundReason:'',
    isShowRefund:false,
    mer_id:0,
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.data.order_id = options.order_id;
    if(options.mer_id){
      this.data.mer_id = parseInt(options.mer_id)
    }
    this.onHttpInit()
    this.setData({
      scrollHeight: app.globalData.windowHeight + 4,
    })
  },
  callPhone(e){
    var phone = e.currentTarget.dataset.phone;
    wx.makePhoneCall({
      phoneNumber: phone,
    })
  },
  /**
     * 获取页面数据的 http请求
     */
  onHttpInit: function () {
    var that = this
    fetchApi.httpPost('/product/order/detail', {
      order_id: that.data.order_id,
      mer_id: that.data.mer_id,
    }, function (res) {
      console.log("订单详情数据", res)
      that.setData({ isLoading: false,   loading: true, netWork: true  })
      if (res.data.code == 0) {
        var order = res.data.data.order;
        console.log('order', order)
        that.setData({
          orderinfo: order, 
          address: res.data.data.address
        })
      }
    }, function (res) {
        that.setData({ hasData: true, isLoading: false, loading: true,  netWork: true })
    })
  },
  preImg: function (t) {
    console.log("preSunImg", t)
    var c = [];
    c.push(this.data.warmHeart.payImgUrl);
    common_Js.preImg(0, c)
  },
  //扫码核销
  goVerifyQrCode(e){
    console.log('goVerifyQrCode',e);
    var orderId = e.currentTarget.dataset.orderid;
    var infoId = e.currentTarget.dataset.infoid;
    wx.navigateTo({
      url: '/pages/order/verify/index?order_id=' + orderId + '&info_id=' +infoId,
    })
  },
  //去评价
  goAppraise:function(e){
    console.log('goAppraise e',e)
    var orderid = e.currentTarget.dataset.orderid;
    var infoid = e.currentTarget.dataset.infoid;
    wx.navigateTo({
      url: '/pages/order/appraise/appraise?order_id=' + orderid + '&infoid=' + infoid,
    })
  },
})